package com.econ.powercloud.ems.common.enums;

/**
 * @Author : wan
 * @Description :
 * @Date : 2020/11/19 9:40
 * @Modified by : wan
 */
public enum DeviceType implements EnumMethod {
    //储能站设备
    STATION(0,"station","储能站"),
    //PCS设备
    PCS(1, "pcs","PCS"),
    //BAMS设备
    BAMS(2, "bams","BAMS"),
    //电池簇
    CLUSTER(3,"bmu","电池簇"),
    //PCS模块
    PCU(5,"pcu","PCS模块"),
    //多功能电表
    MULTIFUNCTION_METER(6,"parallel","并网点多功能电能表"),
    //储能站计量电能表
    MEASURING_METER(7,"metering_meter","计量电能表"),
    //集装箱空调
    AIR_CONDITIONER(8,"air_conditioner","空调"),
    //储能装置BMS
    EQUIPMENT_BMS(9,"bms","BMS总控"),
    //PCS总控(储能装置PCS)
    EQUIPMENT_PCS(10,"pcs_total","PCS总控"),
    //储能装置
    EQUIPMENT(11,"equipment","储能装置"),
    //空调的父类
    AIR_CONDITIONER_PAR(12,"air_toal","空调系统"),
    //电表父类
    METER_PAR(13,"meter","电表系统"),
    //辅助系统(父类)
    AUXILIARY(15,"auxiliary","辅助"),
    //设备电表(例如:空调电表,风机电表)
    DEVICE_METER(18,"device_meter","设备电表"),
    //相设备
    PHASE(19,"phase","相(A/B/C)"),
    //保护设备
    PROTECT_DEVICE(20,"protect_device","保护设备"),
    //保护设备子设备
    CHILD_PROTECT_DEVICE(21,"child_protect_device","保护子设备"),
    //辅助子设备
    CHILD_AUXILIARY(22,"child_auxiliary","辅助子设备"),
    //液冷设备
    SURFACE(23,"surface","液冷设备"),
    //控制器
    CONTROL(24,"control","控制器"),
    //簇下单体信息
    BMU_MONOMER(26,"bmu_monomer","簇单体"),
    //其他设备
    OTHER(40,"other","其他设备"),
    ;

    private Integer code;
    private String codeInScene;
    private String desc;

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public String getCodeInScene() {
        return codeInScene;
    }

    DeviceType(int code, String codeInScene, String desc){
        this.code=code;
        this.codeInScene=codeInScene;
        this.desc=desc;
    }

    public static Integer fromCodeInScene(String codeInScene){
        for(DeviceType type: DeviceType.values()){
            if(type.getCodeInScene().equals(codeInScene)){
                return type.getCode();
            }
        }
        return null;
    }

    public static DeviceType fromCode(Integer code){
        for(DeviceType type: DeviceType.values()){
            if(type.getCode().equals(code)){
                return type;
            }
        }
        return null;
    }
}
